/******************************************************************************
 * Copyright (C) 2017 Chengdu Dlhd information industry co. LTD.
 * All Rights Reserved.
 * 本软件为成都顶联互动信息产业有限公司开发研制。未经本公司正式书面同意，其他任何个人、团体不得使用、复制、修改或发布本软件.
 *****************************************************************************/
package net.dgg.dggcloud.service.jrcrm.service.cms;

import net.dgg.dggcloud.service.common.base.service.BaseService;
import net.dgg.dggcloud.service.jrcrm.dao.cms.SystemNoticeDao;
import net.dgg.dggcloud.service.jrcrm.entity.cms.SystemNotice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


/**
 * @ClassName: EarlyWarningMessageService
 * @Description: 系统公告逻辑类
 * @author duqian
 * @date 2017年11月06日11:30:00
 *
 */
@Service
public class SystemNoticeService extends BaseService {
    @Autowired
    private SystemNoticeDao systemNoticeDao;

    /**
     * 查询系统公告
     * @param map title 标题
     *
     * @return
     */
    public List<Map> listSystemNoticeByMap(Map map){
        return systemNoticeDao.listSystemNoticeByMap(map);
    }

    public Integer countSystemNoticeByMap(Map map){
        return systemNoticeDao.countSystemNoticeByMap(map);
    }

    /**
     * 插入系统公告
     * @param systemNotice
     */
    public void insertSystemNotice(SystemNotice systemNotice){
        try {
            repository.save(systemNotice);
        }catch (Exception e)        {
            throw new RuntimeException("fail");
        }
    }

    /**
     * 根据id删除系统公告
     * @param arryIds
     */
    public void deleteSystemNoticeByIdHiber(String[] arryIds) {
        try {
            for (int i = 0; i < arryIds.length; i++) {
                this.repository.deleteEntityById(SystemNotice.class, Long.parseLong(arryIds[i]));
            }
        } catch (Exception e)        {
            throw new RuntimeException("fail");
        }
    }
}
